<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="pret" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="busOpportunityUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/BusOpportunityDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 商机统计 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="predict_theme">
                  <el-input v-model="pret.predict_theme" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户" prop="predict_client">
                  <el-select style='width:100%' v-model="pret.client_id">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in client" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="月预计销售额" prop="predict_optno">
                  <el-input v-model="pret.predict_optno" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="关闭可能性" prop="reckon_clised">
                  <el-input v-model="pret.reckon_clised" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="提醒时间" prop="predict_remindate">
                  <el-date-picker v-model="pret.predict_remindate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="商机描述" prop="predict_des">
                  <el-input type="textarea" v-model="pret.predict_des" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="经理" prop="client_manager">
                  <el-select style='width:100%' v-model="pret.person_id">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
          <el-button @click="busOpportunityUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/BusOpportunityDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'商机明细'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'BusOpportunityUp',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        pret: {
          predict_theme: null,
          client_id: null,
          predict_optno: null,
          reckon_clised: null,
          predict_remindate: null,
          predict_des: null,
          person_id: null,
        },
        client: [],
        person: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "1BF69B6D830144DA817BDEE6290C9AEA",
        name: "商机管理",
        selected: "商机明细"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/PotentialAdmin/busOpportunityUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      busOpportunityUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/PotentialAdmin/busOpportunityUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/BusOpportunityDet/busOpportunityDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
